package com.zh.jwt.common.jwt;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author hezihao
 * @version 1.0
 * <p>
 * @date 2020/9/17 6:55 下午
 * <p>
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {
    @Bean
    public AuthInterceptor authInterceptor() {
        return new AuthInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry
                //添加Token验证拦截器
                .addInterceptor(authInterceptor())
                //拦截所有请求
                .addPathPatterns("/**");
    }
}